#include<reg51.h>
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,
															 0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char second;
unsigned char i;
void main()
{
	TMOD=0x01;
	EA=1;
	ET0=1;
	TH0=(65536-50000)/256;
	TL0=(65536-50000)%256;
	TR0=1;
	second=0;
	P2=0xfe;
	while(1)
	{
		P1=dispcode[second/10]; //显示十位
		P1 = 0x00;					//熄灭数码管去重影
		P2=(P2<<1)|0x01;    //循环左移一位
		P1=dispcode[second%10]; //显示个位
		P1 = 0x00;					//熄灭数码管去重影
		if(P2 == 0xfd)			//当循环左移到P2.1口时
			P2 = 0xfe;				//重置回到P2.0口
	}
}

void t0(void) interrupt 1 using 0
{
	unsigned char tcnt;
	tcnt++;
	if(tcnt==20)
	{
		tcnt=0;
		second--;
	}
	if(second==00)
	{
		second=60;
	}
	TH0=(65536-50000)/256;
	TL0=(65536-50000)%256;
}
